package com.socket.socketTest;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * LoginServer--bdqnPractice
 *
 * @author: Jovi
 * @createTime: 2017-09-06 16:14
 **/
public class LoginServer {

    public static void main(String[] args) {
        try {
            ServerSocket ss = new ServerSocket(8800);
            Socket socket = ss.accept();

            InputStream is = socket.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));

            String info;
            while ((info = br.readLine()) != null) {
                System.out.println("客户端发送的请求是：" + info);
            }

            OutputStream os = socket.getOutputStream();
            PrintWriter pw = new PrintWriter(os);

            String repay = "This is Server";
            pw.write(repay);
            // pw.flush();
            pw.close();
            os.close();
            br.close();
            is.close();
            ss.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
